<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta content="yes" name="apple-mobile-web-app-capable" />
		<meta content="black" name="apple-mobile-web-app-status-bar-style" />
		<meta content="telephone=no" name="format-detection" />
		<meta content="email=no" name="format-detection" />
		<title>终端列表</title>


		<link rel="stylesheet" href="../../css/s_plus.css" />
		<link rel="stylesheet" href="../../css/base.css?time=222" />
		<link rel="stylesheet" href="../../css/layout.css" />
		<link rel="stylesheet" href="../../css/choice.css" />
		<script type="text/javascript" src="../../libs/vue.js"></script>
		<script type="text/javascript" src="../../js/jquery.1.9.1.min.js"></script>
		<script type="text/javascript" src="../../js/app/url.js"></script>
		<script type="text/javascript" src="../../libs/hui.js"></script>
		<script type="text/javascript" src="../../js/s_plus.js"></script>
		<script type="text/javascript" src="../../js/md5.js"></script>
		<script type="text/javascript" src="../../js/app/api.js"></script>
		<script type="text/javascript" src="../../js/control/mescroll/mescroll.min.js"></script>
		<link rel="stylesheet" href="../../js/control/mescroll/mescroll.min.css" />
		<!--<script type="text/javascript" src="../work/menu.js"></script>-->


	</head>

	<body>

		<div id="app" style="height: 100%;">
			<section class="add_btn">
				<a class="minor_btn" @click="addWork"><i class="iconfont">&#xe626;</i></a>
			</section>

			<section id="wrapper" class="wrapper">
				<section class="pusher">
					<section class="sidenav sidebtn">
						<!--侧边栏-->

					</section>

					<div id="myscroll" class="myscroll">
						<section class="mainbody" id="app">
							<!--正文-->
							<header class="f_l maxbox header">
								<a class="side_arrow f_l arrow_l" data-effect="sidebtn"><i class="iconfont">&#xe600;</i></a>
								<h1 class="f_l">
          <a @click="gisMap">
            <i class="iconfont">&#xe608;</i>
            <b>GIS地图</b>
          </a>
          
          
          
          
          <a class="cur">
            <i class="iconfont">&#xe61f;</i>
            <b>终端列表</b>

          </a>
        </h1>
								<!--<a class="f_r arrow_r" href="javascript:void(0);"><i class="iconfont">&#xe888;</i></a>
        <ul class="head_nav">
          <li><a href="">告警</a></li>
          <li><a href="">施工</a></li>
          <li><a href="">正常</a></li>
        </ul>-->
							</header>
							<section class="f_l maxbox work_list">
								<dl v-for="item in lists">
									<a @click="detail(item)">
	
										<dd class="txt_list">
											<p><em>设备编号：</em>{{item.TERMIMAL_CODE}}</p>
											<p><em>安装时间：</em>{{item.INSTALL_TIME}}</p>
										</dd>
										<!--<div class="sig bg_red">{{showStatus(item.WORK_STATE)}}</div>-->
									</a>
								</dl>
							</section>

						</section>
				</section>
			</section>


			</div>

		</div>
		<script>
				//动态插入公用菜单JS
			var menuJsPath = "../work/menu.js?time=";
			 var randomh=Math.random();
		     var e = document.getElementsByTagName("script")[0];
		     var d = document.createElement("script");
		     d.src = menuJsPath+randomh+"";
		     d.type = "text/javascript"; 
		     d.async = true;
		     d.defer = true;
		     e.parentNode.insertBefore(d,e);

			
	
			var sp = new Vue({
				el: "#app",
				data: {
					username: "",
					keep: [],
					lists: []

				},
				methods: {

					addWork: function() {
						localStorage.setItem("type","baozhuang");
						hui.open("searchDevices.html?s="+apiManage.getNow(), {}, true, {});
//						hui.open("expand.html?time="+apiManage.getNow(), {}, true, {});
					},
					detail: function(cell) {
						//							console.log(pid);
						localStorage.setItem("cell", JSON.stringify(cell));
						hui.open("terminal_show.html?time=" + apiManage.getNow(), {}, true, {});


					},
					logout: function() {
						console.log('2222222');
						hui.open("../../login.html", {}, true, {});
					},
					showType: function(param) {
						if(param == '1') {
							return "一般告警";
						} else {
							return "严重告警";

						}
					},
					showStatus: function(param) {
						var text = "";
						//10	新建	work_state	
						//20	待指派	work_state	
						//30	待接收	work_state	
						//40	待处理	work_state	
						//50	进一步处理	work_state	
						//60	已完成	work_state	
						//90	已取消
						if(param == '10') {
							text = '新建';
						} else if(param == '20') {
							text = '待指派';
						} else if(param == '30') {
							text = '待接收';
						} else if(param == '40') {
							text = '待处理';
						} else if(param == '50') {
							text = '进一步处理';
						} else if(param == '60') {
							text = '进已完成';
						} else {
							text = '已取消';
						}

						return text;

					},
					gisMap: function() {
						hui.open("terminal_map.html", {}, true, {});

					}
				},
				mounted: function() {
					//创建MeScroll对象,down可以不用配置,因为内部已默认开启下拉刷新,重置列表数据为第一页
					//解析: 下拉回调默认调用mescroll.resetUpScroll(); 而resetUpScroll会将page.num=1,再执行up.callback,从而实现刷新列表数据为第一页;
					var self = this;
					self.mescroll = new MeScroll("myscroll", { //请至少在vue的mounted生命周期初始化mescroll,以确保您配置的id能够被找到
						up: {
							auto: true,
							callback: refreshData,
							isBounce: false,
							empty: {
								warpId: "no_data",
								tip: "-------暂无数据-------"
							},
						}
					});

				}
			});



		var path = urlManager.getTerminalBuilds();
			var username = localStorage.getItem("username");
			var sec = localStorage.getItem("sec_pwd");
			var time = getNow();
			var key = "loginName=" + username + "&passWord=" + sec + "&time=" + time;

			var paramKey = hex_md5(key);
	
			console.log(path);



			function refreshData(page) {


           console.log("终端报装列表path2---"+path);
				$.ajax({
					type: "GET",
					url: path,
					beforeSend: function(request) {
						request.setRequestHeader("loginName", username);
						request.setRequestHeader("time", time);
						request.setRequestHeader("sign", paramKey);
						request.setRequestHeader("Content-Type", "application/text");

					},
					success: function(result) {
						console.log("终端报装列表:" + JSON.stringify(result));
						var datas = result.list;

						if(datas != null) {
							//如果是第一页需手动制空列表 (代替clearId和clearEmptyId的配置)
							if(page.num == 1) {
								sp.lists = []
							};

							//更新列表数据
							sp.lists = sp.lists.concat(datas);

							if(sp.lists.length < 10) {
								sp.mescroll.endSuccess(sp.lists.length, false);
							} else {
								sp.mescroll.endSuccess(sp.lists.length, true);

							}

							//sp.mescroll.endBySize(sp.lists.length,dataJson.bodyData.totalItems); //必传参数(当前页的数据个数, 总数据量)
						} else {
							sp.lists = null;
							sp.mescroll.endErr();
						}

					}
				});

			}

			//获取当前时间戳
			function getNow() {
				var timestamp = new Date().getTime();
				return timestamp;
			}
		</script>
	</body>

</html>
<!--侧边栏向左移动效果*该放在head无效-->
<script src="../../js/modernizr.custom.js"></script>
<script src="../../js/classie.js"></script>
<script src="../../js/sidebarEffects.js"></script>